<!DOCTYPE HTML>
<?php header("Access-Control-Allow-Origin:*");  //I have also tried the * wildcard and get the same response
?>
<html>
<head>
  <meta http-equiv=Content-Type content="text/html;charset=utf-8">
  <title>环信Rest API 测试界面</title>
  <script type="text/javascript" src="jquery.js"></script>
  <script type="text/javascript">
  	 function openRegister(){//注册
  	 	$.ajax({  
            type: "post",  
            url: "./testapi.php",   
            crossDomain: true,   
            data: $("#registerform").serialize(),      
            success: function(data) {  
            document.getElementById("resultlable").innerHTML=data;
                alert(data);  
                return false;
            },  
            error: function(data) {  
                alert(data);  
                console.log(data);
                alert("error");  
            }  
       })  ;
  	 	
      //alert("aaaaa");
  	 	return false;
  	 }
  	 
  	 
  	 function userDetails(){//获取用户详细信息
  	 	//alert("aaaaa");
  	 	 	$.ajax({  
            type: "post",  
            url: "./testapi.php",
            crossDomain: true, 
            data: $("#userdetailsfrom").serialize(),      
            success: function(data) {  
            document.getElementById("resultlable").innerHTML=data;
                alert(data);  
                return false;
            },  
            error: function(data) {  
                alert(data);  
                 console.log(data);
                alert("error");  
            }  
       })  ;
       
       return false;
  	 }
  	 
  	 function yy_hxSend(){//发送消息接口
  	 		$.ajax({  
            type: "post",  
            url: "./testapi.php",    
            crossDomain: true, 
            data: $("#yyhxSendfrom").serialize(),      
            success: function(data) {  
            document.getElementById("resultlable").innerHTML=data;
                alert(data);  
                return false;
            },  
            error: function(data) {  
                alert(data); 
                console.log(data);
                alert("error");   
            }  
       })  ;
       
       return false;
  	 }
  </script>
</head>
<body>
	
	 <form name="registerform" id="registerform" method="post" action="" >
	   	<div>
	   		 接口1:注册接口<br /><br />
	   		  用户名：<input type="text" name="username"/><br /><br />
	   		  密		码：<input type="text"  name="password"/><br /><br />
	   		  <input name="mytype" type="hidden" value="1" />
	   			<button  onclick="return openRegister()" type="submit">提交</button>
	   	</div>
   	</form>
      
   	<br /><br /><br /><br />
   	
	 <form name="userdetailsfrom" id="userdetailsfrom" method="post" action="" >
	   	<div>
	   		 接口3:获取指定用户详情接口<br /><br />
	   		  用户名：<input type="text" name="username"/><br /><br />
	   		  <input name="mytype" type="hidden" value="3" />
	   			<button  onclick="return userDetails()" type="submit">提交</button>
	   	</div>
   	</form>
   	
   	<br /><br /><br /><br />
	 <form name="yyhxSendfrom" id="yyhxSendfrom" method="post" action="" >
	   	<div>
	   		 接口5:发送消息接口<br /><br />
	   		  发送方用户名：<input type="text" name="from_user"/><br /><br />
	   		  接收方用户名：<input type="text"  name="username"/><br /><br />
	   		  发送的对象：<input type="text" name="target_type"  value="users"/> <br />注释：给一个或者多个用户(users)或者群组发送消息(chatgroups)<br /><br />
	   		  发送的内容：<br /><textarea name="content" rows="5" cols="50"></textarea><br /><br />
	   		  扩展消息：<br /><textarea name="ext" rows="5" cols="50"></textarea><br /><br />
	   		  <input name="mytype" type="hidden" value="5" />
	   			<button  onclick="return yy_hxSend()" type="submit">提交</button>
	   	</div>
   	</form>
   	
   
   
   <br /><br /><br />
    返回结果：<br /><textarea  id="resultlable" name="resultlable" rows="5" cols="50"></textarea><br /><br />
   
</body>
</html>